/* Bot made by Goten87 add me at Goten87@live.nl
 *
 * Bot made for RSBot And RSBot only if u see the script on a other site please tell Goten87 @ RSBot.org
 * This is my first Bot so its not a Great working bot but it gets the job done
 * Please Report bugs and Errors at http://www.rsbot.org/vb/showthread.php?t=12864
 * 
 * Copyright is going to the maker and PownZ for his Tutorial
 */

import java.awt.Color;
import java.awt.Graphics;
import java.util.Map;

import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.script.GEItemInfo;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.wrappers.RSItemTile;
import com.speljohan.rsbot.script.wrappers.RSNPC;

public class ChickenChaser extends Script implements PaintListener {

	public int[] monsterID = { 2313, 2314, 2315 };
	public int[] arrowsID = { 0000, 0000 };

	public int featherID = 314;
	public int fightAnimation = 390;
	public int CoinID = 995;
	private int featherMarketPrice = 0;
	private String currentState = "Starting up..";

	@Override
	public String getAuthor() {
		return "Goten87";
	}

	public String getDiscription() {
		return "Kills Chickens for u and picks up the Feathers";
	}

	@Override
	public String getName() {
		return "Chicken Chaser";
	}

	@Override
	public String getScriptCategory() {
		return "Combat";
	}

	@Override
	public String getScriptDescription() {
		String html = "";

		html += "<html><body>";
		html += "<center><h2>Project Name: " + getName() + "</h2></center><br>";
		html += "<strong>Author:</strong> " + getAuthor() + "<br>";
		html += "<strong>Version:</strong> " + getVerzion() + "<br>";
		html += "<strong><u>How To Use:</u></strong> " + getToUse() + "<br>";
		html += "<strong>Description:</strong><br>" + getDiscription() + "<br>";

		html += "<br><br><hr>";
		html += "<table width='100%'><tr align='right'><td>CopyRight: "
				+ getAuthor() + "</td></tr></table>";
		return html;
	}

	public String getToUse() {
		return " go to the farm in falador and start the script";
	}

	public double getVerzion() {
		return 1.4;
	}

	@Override
	public int loop() {

		if (getMyPlayer().isMoving()) {
			return 800;
		}

		if (getMyPlayer().getAnimation() == fightAnimation) {
			currentState = "Fighting a Chicken";
			return 800;
		}

		if (isInventoryFull()) {
			dropAllExcept(featherID, CoinID);
			currentState = "Emty your bag";
		}

		final RSNPC npc = getNearestNPCByID(monsterID);
		if (npc == null) {
			return 2;
		}
		currentState = "Looking for a Chicken";
		atNPC(npc, "Attack");
		wait(4000);

		final RSItemTile Feather = getGroundItemByID(featherID);
		if (Feather != null) {
			wait(500);
			atTile(Feather, "Feather");
			currentState = "Looking for Feathers";

		}

		final RSItemTile Coin = getGroundItemByID(CoinID);
		if (Coin != null) {

			atTile(Coin, "Coins");
			wait(500);
			currentState = "Looking for Coins";
		}

		return 300;
	}

	@Override
	public void onFinish() {
		Bot.getEventManager().removeListener(PaintListener.class, this);
		log("Chicken Chaser Shutdown");
		return;
	}

	public void onRepaint(final Graphics g) {
		if (isLoggedIn()) {
			g.setColor(Color.YELLOW);
			g.drawString("Chicken Chaser V " + getVersion(), 250, 88);
			g.drawString("Feather price:" + featherMarketPrice, 250, 98);
			g.drawString("State: Comming soon" + currentState, 250, 108);
		}

	}

	@Override
	public boolean onStart(final Map<String, String> args) {
		log("Getting market prices for Feathers.");
		final GEItemInfo feather = grandExchange.loadItemInfo(featherID);
		featherMarketPrice = feather.getMarketPrice();
		log("Done getting market prices!");
		log("Grand Exchange: Feathers are now" + featherMarketPrice + "Coins");
		log("Done loading, script is starting up!");
		return true;
	}

	// end Script
}